using System;
using System.Collections.Generic;
using System.Text;
using NHibernate;

namespace NDomain.ExampleModels.BloggingSystem.Infrastructure
{
    public class CurrentSessionProxy : ISession
    {
        private ISessionFactory _sessionFactory;

        public CurrentSessionProxy (ISessionFactory sessionFactory)
        {
            _sessionFactory = sessionFactory;
        }

        private ISession Session
        {
            get { return _sessionFactory.GetCurrentSession(); }
        }

        #region ISession Members

        public ITransaction BeginTransaction(System.Data.IsolationLevel isolationLevel)
        {
            return Session.BeginTransaction(isolationLevel);
        }

        public ITransaction BeginTransaction()
        {
            return Session.BeginTransaction();
        }

        public void CancelQuery()
        {
            Session.CancelQuery();
        }

        public void Clear()
        {
            Session.Clear();
        }

        public System.Data.IDbConnection Close()
        {
            return Session.Close();
        }

        public System.Data.IDbConnection Connection
        {
            get { return Session.Connection; }
        }

        public bool Contains(object obj)
        {
            return Session.Contains(obj);
        }

        public ICriteria CreateCriteria(Type persistentClass, string alias)
        {
            return Session.CreateCriteria(persistentClass, alias);
        }

        public ICriteria CreateCriteria(Type persistentClass)
        {
            return Session.CreateCriteria(persistentClass);
        }

        public IQuery CreateFilter(object collection, string queryString)
        {
            return Session.CreateFilter(collection, queryString);
        }

        public IMultiQuery CreateMultiQuery()
        {
            return Session.CreateMultiQuery();
        }

        public IQuery CreateQuery(string queryString)
        {
            return Session.CreateQuery(queryString);
        }

        public ISQLQuery CreateSQLQuery(string queryString)
        {
            return Session.CreateSQLQuery(queryString);
        }

        public IQuery CreateSQLQuery(string sql, string[] returnAliases, Type[] returnClasses)
        {
            return Session.CreateSQLQuery(sql, returnAliases, returnClasses);
        }

        public IQuery CreateSQLQuery(string sql, string returnAlias, Type returnClass)
        {
            return Session.CreateSQLQuery(sql, returnAlias, returnClass);
        }

        public int Delete(string query, object[] values, NHibernate.Type.IType[] types)
        {
            return Session.Delete(query, values, types);
        }

        public int Delete(string query, object value, NHibernate.Type.IType type)
        {
            return Session.Delete(query, value, type);
        }

        public int Delete(string query)
        {
            return Session.Delete(query);
        }

        public void Delete(object obj)
        {
            Session.Delete(obj);
        }

        public void DisableFilter(string filterName)
        {
            Session.DisableFilter(filterName);
        }

        public System.Data.IDbConnection Disconnect()
        {
            return Session.Disconnect();
        }

        public IFilter EnableFilter(string filterName)
        {
            return Session.EnableFilter(filterName);
        }

        public System.Collections.IEnumerable Enumerable(string query, object[] values, NHibernate.Type.IType[] types)
        {
            return Session.Enumerable(query, values, types);
        }

        public System.Collections.IEnumerable Enumerable(string query, object value, NHibernate.Type.IType type)
        {
            return Session.Enumerable(query, value, type);
        }

        public System.Collections.IEnumerable Enumerable(string query)
        {
            return Session.Enumerable(query);
        }

        public void Evict(object obj)
        {
            Session.Evict(obj);
        }

        public System.Collections.ICollection Filter(object collection, string filter, object[] values, NHibernate.Type.IType[] types)
        {
            return Session.Filter(collection, filter, values, types);
        }

        public System.Collections.ICollection Filter(object collection, string filter, object value, NHibernate.Type.IType type)
        {
            return Session.Filter(collection, filter, value, type);
        }

        public System.Collections.ICollection Filter(object collection, string filter)
        {
            return Session.Filter(collection, filter);
        }

        public System.Collections.IList Find(string query, object[] values, NHibernate.Type.IType[] types)
        {
            return Session.Find(query, values, types);
        }

        public System.Collections.IList Find(string query, object value, NHibernate.Type.IType type)
        {
            return Session.Find(query, value, type);
        }

        public System.Collections.IList Find(string query)
        {
            return Session.Find(query);
        }

        public void Flush()
        {
            Session.Flush();
        }

        public FlushMode FlushMode
        {
            get
            {
                return Session.FlushMode;
            }
            set
            {
                Session.FlushMode = value;
            }
        }

        public T Get<T>(object id, LockMode lockMode)
        {
            return Session.Get<T>(id, lockMode);
        }

        public T Get<T>(object id)
        {
            return Session.Get<T>(id);
        }

        public object Get(Type clazz, object id, LockMode lockMode)
        {
            return Session.Get(clazz, id, lockMode);
        }

        public object Get(Type clazz, object id)
        {
            return Session.Get(clazz, id);
        }

        public LockMode GetCurrentLockMode(object obj)
        {
            return Session.GetCurrentLockMode(obj);
        }

        public IFilter GetEnabledFilter(string filterName)
        {
            return Session.GetEnabledFilter(filterName);
        }

        public object GetIdentifier(object obj)
        {
            return Session.GetIdentifier(obj);
        }

        public IQuery GetNamedQuery(string queryName)
        {
            return Session.GetNamedQuery(queryName);
        }

        public bool IsConnected
        {
            get { return Session.IsConnected; }
        }

        public bool IsDirty()
        {
            return Session.IsDirty();
        }

        public bool IsOpen
        {
            get { return Session.IsOpen; }
        }

        public void Load(object obj, object id)
        {
            Session.Load(obj, id);
        }

        public T Load<T>(object id)
        {
            return Session.Load<T>(id);
        }

        public T Load<T>(object id, LockMode lockMode)
        {
            return Session.Load<T>(id, lockMode);
        }

        public object Load(Type theType, object id)
        {
            return Session.Load(theType, id);
        }

        public object Load(Type theType, object id, LockMode lockMode)
        {
            return Session.Load(theType, id, lockMode);
        }

        public void Lock(object obj, LockMode lockMode)
        {
            Session.Lock(obj, lockMode);
        }

        public void Reconnect(System.Data.IDbConnection connection)
        {
            Session.Reconnect(connection);
        }

        public void Reconnect()
        {
            Session.Reconnect();
        }

        public void Refresh(object obj, LockMode lockMode)
        {
            Session.Refresh(obj, lockMode);
        }

        public void Refresh(object obj)
        {
            Session.Refresh(obj);
        }

        public void Replicate(object obj, ReplicationMode replicationMode)
        {
            Session.Replicate(obj, replicationMode);
        }

        public void Save(object obj, object id)
        {
            Session.Save(obj, id);
        }

        public object Save(object obj)
        {
            return Session.Save(obj);
        }

        public void SaveOrUpdate(object obj)
        {
            Session.SaveOrUpdate(obj);
        }

        public object SaveOrUpdateCopy(object obj, object id)
        {
            return Session.SaveOrUpdateCopy(obj, id);
        }

        public object SaveOrUpdateCopy(object obj)
        {
            return Session.SaveOrUpdateCopy(obj);
        }

        public ISessionFactory SessionFactory
        {
            get { return Session.SessionFactory; }
        }

        public ITransaction Transaction
        {
            get { return Session.Transaction; }
        }

        public void Update(object obj, object id)
        {
            Session.Update(obj, id);
        }

        public void Update(object obj)
        {
            Session.Update(obj);
        }

        #endregion

        #region IDisposable Members

        public void Dispose()
        {
            Session.Dispose();
        }

        #endregion
    }
}
